package com.xc.erp.common.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.xc.erp.modules.erp.domain.pojo.JshSupplier;
import com.xc.erp.modules.erp.domain.vo.SupplierVo;
import com.xc.erp.modules.erp.mapper.JshSupplierMapper;
import org.springframework.beans.BeanUtils;

/**
 * EasyExcel导入监听器
 *
 * @author wjw 2022/12/14
 * @DateTime: 2022/12/14 10:45
 */
public class JshSupplierListener extends AnalysisEventListener<SupplierVo> {

    private JshSupplierMapper jshSupplierMapper;

    public JshSupplierListener(JshSupplierMapper jshSupplierMapper){
        jshSupplierMapper = jshSupplierMapper;
    }

    /**
     * 一行一行的进行读取
     * @param supplierVo
     * @param context
     */
    @Override
    public void invoke(SupplierVo supplierVo, AnalysisContext context) {
        JshSupplier supplier = new JshSupplier();
        BeanUtils.copyProperties(supplierVo,supplier);
        jshSupplierMapper.insert(supplier);
    }


    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {

    }
}
